<?php
/**
 * Template Name: Home page
 *
 * This is the most generic template file in a WordPress theme
 * and one of the two required files for a theme (the other being style.css).
 * It is used to display a page when nothing more specific matches a query. 
 * E.g., it puts together the home page when no home.php file exists.
 * Learn more: http://codex.wordpress.org/Template_Hierarchy
 *
 * @package WordPress
 * @subpackage ACFood4U
 * @since Twenty Ten 1.0
 */

get_header(); ?>
   
    <!-- start of main box -->
      <div class="mainBox">
        <div class="leftBox">
          <div class="featureletBox">
            <div class="featureLets">
            <!-- ==================== RESTAUTANT OF THE WEEK ==================== -->
              
              <?php
					$querystr = "
					SELECT wposts.* 
					FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
					WHERE wposts.ID = wpostmeta.post_id 
					AND wpostmeta.meta_key = 'restaurantOfTheWeek' 
					AND wpostmeta.meta_value = 'yes'
					AND wposts.post_status = 'publish' 
					AND wposts.post_type = 'post' 
					AND wposts.post_date < NOW() 
					ORDER BY wposts.post_date DESC LIMIT 1
					";
					$restuarantWeek = $wpdb->get_results($querystr, OBJECT);
				?>
              
              <!-- ==================== RESTAURANT SHORT DETAILS ==================== -->
              
              <?php if ($restuarantWeek): ?>
              <?php foreach ($restuarantWeek as $post): ?>
              <?php setup_postdata($post); ?>
              <?php if (get_post_meta($post->ID, "featureImage") !='') { ?>
              <a href="<?php the_permalink(); ?>"><img src="<?php echo get_post_meta($post->ID, "featureImage", true); ?>" alt="<?php the_title(); ?> icon" width="171" height="96" border="0" /></a>
              <?php } ?>
              <h3>FEATURE RESTAURANT</h3>
              <p><strong><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></strong></p>
              <?php the_excerpt('more_link_text', TRUE, 'more_file'); ?>
              <?php endforeach; ?>
              <?php else : ?>
              <h2 class="center">Not Found</h2>
              <p>Sorry, tag --> recipeWeek.</p>
              <?php endif; ?>
            </div>
            <div class="featureLets">
              <!-- ==================== RECIPE OF THE WEEK ==================== -->
              
              <?php
					$querystr = "
					SELECT wposts.* 
					FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
					WHERE wposts.ID = wpostmeta.post_id 
					AND wpostmeta.meta_key = 'recipeOfTheWeek' 
					AND wpostmeta.meta_value = 'yes'
					AND wposts.post_status = 'publish' 
					AND wposts.post_type = 'post' 
					AND wposts.post_date < NOW() 
					ORDER BY wposts.post_date DESC LIMIT 1
					";
					$recipeWeek = $wpdb->get_results($querystr, OBJECT);
				?>
              
              <!-- ==================== RECIPE SHORT DETAILS ==================== -->
              
              <?php if ($recipeWeek): ?>
              <?php foreach ($recipeWeek as $post): ?>
              <?php setup_postdata($post); ?>
              <?php if (get_post_meta($post->ID, "featureImage") !='') { ?>
              <a href="<?php the_permalink(); ?>"><img src="<?php echo get_post_meta($post->ID, "featureImage", true); ?>" alt="<?php the_title(); ?> icon" width="171" height="96" border="0" /></a>
              <?php } ?>
              <h3>RECIPE OF THE WEEK</h3>
              <p><strong><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></strong></p>
              <?php the_excerpt('more_link_text', TRUE, 'more_file'); ?>
              <?php endforeach; ?>
              <?php else : ?>
              <h2 class="center">Not Found</h2>
              <p>Sorry, tag --> recipeWeek.</p>
              <?php endif; ?>
            </div>
            <div class="featureLets">
              <!-- ==================== VIDEO ==================== -->
              
              <?php
					$querystr = "
					SELECT wposts.* 
					FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
					WHERE wposts.ID = wpostmeta.post_id 
					AND wpostmeta.meta_key = 'newVideo' 
					AND wpostmeta.meta_value = 'yes'
					AND wposts.post_status = 'publish' 
					AND wposts.post_type = 'post' 
					AND wposts.post_date < NOW() 
					ORDER BY wposts.post_date DESC LIMIT 1
					";
					$newVideo = $wpdb->get_results($querystr, OBJECT);
				?>
              
              <!-- ==================== VIDEO ==================== -->
              
              <?php if ($newVideo): ?>
              <?php foreach ($newVideo as $post): ?>
              <?php setup_postdata($post); ?>
              <?php if (get_post_meta($post->ID, "featureImage") !='') { ?>
              <a href="<?php the_permalink(); ?>"><img src="<?php echo get_post_meta($post->ID, "featureImage", true); ?>" alt="<?php the_title(); ?> icon" width="171" height="96" border="0" /></a>
              <?php } ?>
              <h3>NEW VIDEO</h3>
              <p><strong><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></strong></p>
              <?php the_excerpt('more_link_text', TRUE, 'more_file'); ?>
              <?php endforeach; ?>
              <?php else : ?>
              <h2 class="center">Not Found</h2>
              <p>Sorry, tag --> newVideo.</p>
              <?php endif; ?>
            </div>
            <div class="featureLast">
              <!-- ==================== CHEF ==================== -->
              
              <?php
					$querystr = "
					SELECT wposts.* 
					FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
					WHERE wposts.ID = wpostmeta.post_id 
					AND wpostmeta.meta_key = 'featureChef' 
					AND wpostmeta.meta_value = 'yes'
					AND wposts.post_status = 'publish' 
					AND wposts.post_type = 'post' 
					AND wposts.post_date < NOW() 
					ORDER BY wposts.post_date DESC LIMIT 1
					";
					$chefDetails = $wpdb->get_results($querystr, OBJECT);
				?>
              
              <!-- ==================== CHEF ==================== -->
              
              <?php if ($chefDetails): ?>
              <?php foreach ($chefDetails as $post): ?>
              <?php setup_postdata($post); ?>
              <?php if (get_post_meta($post->ID, "featureImage") !='') { ?>
              <a href="<?php the_permalink(); ?>"><img src="<?php echo get_post_meta($post->ID, "featureImage", true); ?>" alt="<?php the_title(); ?> icon" width="171" height="96" border="0" /></a>
              <?php } ?>
              <h3>FEATURED CHEF</h3>
              <p><strong><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></strong></p>
              <?php the_excerpt('more_link_text', TRUE, 'more_file'); ?>
              <?php endforeach; ?>
              <?php else : ?>
              <h2 class="center">Not Found</h2>
              <p>Sorry, tag --> chefDetails.</p>
              <?php endif; ?>
            </div>
          </div>
          <div id="tabs" class="categoryContainer" style="border:none;">
            <div class="categoryTabHolder">
              <ul class="headerx">
                <li style="	border:none; background:none; margin:0; padding:0"><a href="#tabs-1" class="byRestaurant">By Restaurant</a></li>
                <li><a href="#tabs-2" class="byCuisine">By Location</a></li>
                <li><a href="#tabs-3" class="byCaterers">By Caterers</a></li>
                <li><a href="#tabs-4" class="byLocation">By Cuisine</a></li>
              </ul>
            </div>
            <div class="categoryMainContainer">
              <div class="top"></div>
              <div class="middle">
              	<div id="tabs-1">
					Display restaurant category list here.
                </div>
                <div id="tabs-2">
					Display restaurant category by location here.
                </div>
				<div id="tabs-3">
					Display restaurant category by caterer here.
                </div>
				<div id="tabs-4">
                	Display restaurant category by cuisine here.
                </div>
              </div>
              <div class="bottom"></div>
            </div>
          </div>
        </div>
        <!-- the side bar -->
		<?php get_sidebar(); ?>
	</div>
<?php get_footer(); ?>
